// const { getUser,checkAge,checkUsername ,regist : registService, checkLogin } = require('../services/users')
const userService = require('../services/users')
//*login页面
async function login(ctx,next){
  await ctx.render('login')
}
//*regist页面
async function regist(ctx,next){
  await ctx.render('regist')
}

//*检查用户名
async function checkName(ctx,next){
  const{ username } =  ctx.request.query;
  let data ={
    status:'success'
  }
  if(userService.checkNameDuplicate(username)){
    data.status = 'failed';
    data.message = '用户名不符合要求'
  }else{
    const result = await userService.checkNameDuplicate();
    if(result){
      data.status = 'failed';
    data.message = '用户名重复'
    }
  }
  ctx.response.body = data;
}
// async function userRegist(ctx,next){
//   const { username , password , age , gender} = ctx.require.body;
//   let data = {
//     status:'success'
//   }
  
  module.exports = {
    login,
    regist,
    checkName,
    // nameRegist,
    // passwordRegist,
    // repasswordRegist,
    
  }